import doctest
from DateTime import DateTime

# Standard options for DocTests
optionflags =  (doctest.ELLIPSIS |
                doctest.NORMALIZE_WHITESPACE |
                doctest.REPORT_ONLY_FIRST_FAILURE)

def addMember(self, username, fullname="", email="", roles=('Member',), last_login_time=None):
    self.portal.portal_membership.addMember(username, 'secret', roles, [])
    member = self.portal.portal_membership.getMemberById(username)
    member.setMemberProperties({'fullname': fullname, 'email': email,
                                'last_login_time': DateTime(last_login_time),})

def setupDefaultMembers(self):
    addMember(self, 'member1', 'Member one', roles=('Member',))
    addMember(self, 'member2', 'Member two', roles=('Member',))
    addMember(self, 'manager1', 'Manager one', roles=('Manager',))
    self.member1 = self.portal.portal_membership.getMemberById('member1')
    self.member2 = self.portal.portal_membership.getMemberById('member2')
    self.manager1 = self.portal.portal_membership.getMemberById('manager1')

def setupZopista(self):
    self.setRoles(('Manager',))
    self.portal.invokeFactory('Zopista', 'divulgacoes')
    self.zopista = self.portal.divulgacoes
    self.portal.portal_workflow.doActionFor(self.zopista, 'publish')